package com.lam.common.components.data.model;

import java.util.HashSet;
import java.util.Set;

public class DataFeature {
	
	/** 是否进行深度遍历解析 */
	private boolean deep =  true;
	
	/** 是否内部自动创建的 */
	private boolean isInner = false;
	
	private Set<Object> injectedSet;
	
	public DataFeature() {}
	
	public DataFeature(DataFeature dataFeature) {
		if(dataFeature != null) {
			this.deep = dataFeature.deep;
			this.isInner = true;
		}
	}
	
	public static DataFeature create(DataFeature dataFeature) {
		return dataFeature != null && dataFeature.isInner ? dataFeature : new DataFeature(dataFeature);
	}
	
	public static DataFeature create() {
		return new DataFeature();
	}
	
	public boolean injectedContains(Object o) {
		
		return injectedSet != null && injectedSet.contains(o);
	}

	public void addInjected(Object object) {
		if(object == null) {
			return ;
		}
		
		if(injectedSet == null) {
			injectedSet = new HashSet<>();
		}
		injectedSet.add(object);
	}

	public boolean deep() {
		return deep;
	}

	public DataFeature deep(boolean deep) {
		this.deep = deep;
		return this;
	}

	public boolean isInner() {
		return isInner;
	}

	public DataFeature setInner(boolean isInner) {
		this.isInner = isInner;
		return this;
	}

}
